using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Data_TypeInfo_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Data.TypeInfo);
            args = new Type[]{typeof(System.Object)};
            method = type.GetMethod("Compare", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Compare_0);
            args = new Type[]{typeof(System.String)};
            method = type.GetMethod("IsSubType", flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, IsSubType_1);

            field = type.GetField("Index", flag);
            app.RegisterCLRFieldGetter(field, get_Index_0);
            app.RegisterCLRFieldSetter(field, set_Index_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Index_0, AssignFromStack_Index_0);
            field = type.GetField("type", flag);
            app.RegisterCLRFieldGetter(field, get_type_1);
            app.RegisterCLRFieldSetter(field, set_type_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_type_1, AssignFromStack_type_1);
            field = type.GetField("name", flag);
            app.RegisterCLRFieldGetter(field, get_name_2);
            app.RegisterCLRFieldSetter(field, set_name_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_name_2, AssignFromStack_name_2);
            field = type.GetField("loader", flag);
            app.RegisterCLRFieldGetter(field, get_loader_3);
            app.RegisterCLRFieldSetter(field, set_loader_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_loader_3, AssignFromStack_loader_3);


            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Data.TypeInfo[s]);


        }


        static StackObject* Compare_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Object @obj = (System.Object)typeof(System.Object).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.Data.TypeInfo instance_of_this_method = (huqiang.Data.TypeInfo)typeof(huqiang.Data.TypeInfo).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.Compare(@obj);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }

        static StackObject* IsSubType_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* ptr_of_this_method;
            StackObject* __ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.String @obj = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            huqiang.Data.TypeInfo instance_of_this_method = (huqiang.Data.TypeInfo)typeof(huqiang.Data.TypeInfo).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.IsSubType(@obj);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method ? 1 : 0;
            return __ret + 1;
        }


        static object get_Index_0(ref object o)
        {
            return ((huqiang.Data.TypeInfo)o).Index;
        }

        static StackObject* CopyToStack_Index_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TypeInfo)o).Index;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Index_0(ref object o, object v)
        {
            ((huqiang.Data.TypeInfo)o).Index = (System.Int32)v;
        }

        static StackObject* AssignFromStack_Index_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @Index = ptr_of_this_method->Value;
            ((huqiang.Data.TypeInfo)o).Index = @Index;
            return ptr_of_this_method;
        }

        static object get_type_1(ref object o)
        {
            return ((huqiang.Data.TypeInfo)o).type;
        }

        static StackObject* CopyToStack_type_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TypeInfo)o).type;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_type_1(ref object o, object v)
        {
            ((huqiang.Data.TypeInfo)o).type = (System.Type)v;
        }

        static StackObject* AssignFromStack_type_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Type @type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.TypeInfo)o).type = @type;
            return ptr_of_this_method;
        }

        static object get_name_2(ref object o)
        {
            return ((huqiang.Data.TypeInfo)o).name;
        }

        static StackObject* CopyToStack_name_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TypeInfo)o).name;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_name_2(ref object o, object v)
        {
            ((huqiang.Data.TypeInfo)o).name = (System.String)v;
        }

        static StackObject* AssignFromStack_name_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.String @name = (System.String)typeof(System.String).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.TypeInfo)o).name = @name;
            return ptr_of_this_method;
        }

        static object get_loader_3(ref object o)
        {
            return ((huqiang.Data.TypeInfo)o).loader;
        }

        static StackObject* CopyToStack_loader_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Data.TypeInfo)o).loader;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_loader_3(ref object o, object v)
        {
            ((huqiang.Data.TypeInfo)o).loader = (huqiang.Data.DataLoader)v;
        }

        static StackObject* AssignFromStack_loader_3(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Data.DataLoader @loader = (huqiang.Data.DataLoader)typeof(huqiang.Data.DataLoader).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Data.TypeInfo)o).loader = @loader;
            return ptr_of_this_method;
        }




    }
}
